export default class Result<T> {
    code: number | 200;
    data: T | null;
    msg: string;
  
    constructor(code: number | 200, data: T | null, msg?: string) {
      this.code = code;
      this.data = data;
      this.msg = msg;
    }
  
    static ok<T>(data?: T | null): Result<T> {
      return new Result<T>(200, data, "成功");
    }
  
    static err<T>(data?: T | null): Result<T> {
      return new Result<T>(500, data, "失败");
    }
  
    public setCode(code: number | 200) {
      this.code = code;
      return this;
    }
  
    public setData(data: T | null) {
      this.data = data;
      return this;
    }
  
    public setMsg(msg: string) {
      this.msg = msg;
      return this;
    }
  }